package com.google.gwt.sample.dynatablerf.client.widgets;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.Widget;

public class GrifoWidgetFactory {

	public static Button getButton(Image image, Label label) {
		Button button = new Button();
		HorizontalPanel horizontalPanel = new HorizontalPanel();
		if (image != null)
			horizontalPanel.add(image);
		if (label != null)
			horizontalPanel.add(label);
		button.setHTML(horizontalPanel.getElement().getInnerHTML());
		return button;
	}

	public static Button getButton(Image image) {
		return getButton(image, null);
	}

	public static MenuItem getMenuItem(Widget header, MenuBar subMenu) {
		String safeHtml = header.getElement().getInnerHTML();
		MenuItem item = new MenuItem(safeHtml, true, subMenu);
		return item;
	}
}
